<?php

declare (strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */
namespace App\Model;

use Hyperf\Database\Model\SoftDeletes;
class SearchHistory extends Model
{
    use SoftDeletes;
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected ?string $table = 'search_history';
    public function user()
    {
        return $this->belongsTo(User::class, 'user_id');
    }
    /**
     * 接口返回
     * @return array
     */
    public function toApi()
    {
        return ['id' => $this->id, 'search' => $this->search ?? ''];
    }
}